package cn.itsource.org.service.impl;

import cn.itsource.basic.service.impl.BaseServiceImpl;
import cn.itsource.org.domain.Employee;
import cn.itsource.org.domain.Shop;
import cn.itsource.org.mapper.EmployeeMapper;
import cn.itsource.org.mapper.ShopMapper;
import cn.itsource.org.service.IEmployeeService;
import cn.itsource.org.service.IShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ShopServiceImpl  extends BaseServiceImpl<Shop> implements IShopService {
    @Autowired
    private ShopMapper shopMapper;
    @Autowired
    private IEmployeeService employeeService;
    @Override
    public void settlement(Shop shop) {
        //获取admin信息
        Employee admin = shop.getAdmin();
        //保存店主信息
        employeeService.save(admin);
        //保存店铺信息
        shopMapper.save(shop);
        //给员工设置对应的店铺id
        admin.setShop(shop);
        //修改员工信息
        employeeService.update(admin);
    }
}
